Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Update JavaScript build and setup with wp-scripts updates #14440

Merged
merged 8 commits into from
Mar 18, 2019

Conversation

mkaz
Copy link
Member

@mkaz mkaz commented Mar 14, 2019

Description

Closes #13712.

Updates the build and setup section of the JavaScript tutorial with the new simplified commands included in wp-scripts. Removes webpack and babel configs and replaces recommending to use the default configs using wp-scripts build|start

How has this been tested?

Follow the instructions, in the tutorial which includes a simple block you can create to test.
Until the wp-scripts gets published you will need to add a local reference to @wordpress/scripts package.

For me Gutenberg is one directory up from my sample plugin so my package.json entry looks like:

    "@wordpress/scripts": "file:../gutenberg/packages/scripts",

View documentation live on branch here

Depends on #14168

@youknowriad
Copy link
Contributor

Nice ❤️

Copy link
Contributor

@chrisvanpatten chrisvanpatten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! A few small suggestions…

@mkaz
Copy link
Member Author

mkaz commented Mar 14, 2019

@nosolosw @gziolo In my testing, it was still required to install the following packages, they were not picked up as dependencies of @wordpress/scripts

webpack webpack-cli @wordpress/babel-preset-default babel-plugin-transform-react-jsx

The babel-plugin-transform-react-jsx looks to be the only one not specified in the scripts package.json. I'm not sure why the others didn't work for me, my hunch is because of the local package references.

Following the instructions in the docs and installing and it all works great, so much simpler!

@oandregal
Copy link
Member

@mkaz for ESNext we need to land #14168 first. I'm waiting for Travis so I can merge :)

This example oandregal/understanding-gutenberg#7 shows how it works (I'm using JSX syntax and arrow functions in the src/index.js and the build/index.js is transpiled properly).

@chrisvanpatten chrisvanpatten dismissed their stale review March 14, 2019 17:51

changes addressed; awesome stuff @mkaz!

@mkaz mkaz force-pushed the update/js-build-docs branch from c5705e0 to 02f6909 Compare March 14, 2019 17:56
Copy link
Member

@oandregal oandregal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great to see! I pushed some commits, feel free to remove them if you don't like them. I thought it'd be faster to commit than to write the suggestion :)

I'm approving so it's ready to go, although I understand that we want to merge this after the packages' release.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work. Thanks for putting this together and updating with the latest changes introduced. It should be very helpful moving forward. We probably should also reference this document from @wordpress/scripts readme file as well.

Additionally, webpack has a `--watch` flag that will keep the process running, watching for any changes to the `block.js` file and re-building as changes occur. This is useful during development, when you might have a lot of changes in progress.

You can start the watcher by running `npm run dev` in a terminal. You can then edit away in your text editor; after each save, webpack will automatically build. You can then use the familiar edit/save/reload development process.
Now, when you run `npm run start` a watcher will run in the terminal. You can then edit away in your text editor; after each save, it will automatically build. You can then use the familiar edit/save/reload development process.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next step, hot module reloading support? :)

@gziolo gziolo added the [Release] Do Not Punt Used to indicate the issue or pull request must not be moved from the assigned milestone label Mar 15, 2019
…uild-setup.md

Co-Authored-By: mkaz <marcus@mkaz.com>
@youknowriad youknowriad merged commit 74c0ed7 into master Mar 18, 2019
@youknowriad youknowriad deleted the update/js-build-docs branch March 18, 2019 07:18
@youknowriad youknowriad added this to the 5.3 (Gutenberg) milestone Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Release] Do Not Punt Used to indicate the issue or pull request must not be moved from the assigned milestone [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants